package digital.store.springmvc.service;

import java.util.Collection;
import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import digital.store.springmvc.dao.CategoryDao;
import digital.store.tutorial.springmvc.model.Category;

@Service
@Transactional
public class CategoryService {
    @Autowired
    private CategoryDao categoryDao;
	    
    @Transactional
    public void saveOrUpdate(Category category) {
    	categoryDao.saveOrUpdate(category);
	}
	    
	@Transactional
	public void delete(Long categoryId) {
	    categoryDao.delete(categoryId);
	}
	    
	public Collection<Category> findAll() {
	    return categoryDao.findAll();
	}
	
	public Category findById(Long categoryId) {
	    return categoryDao.findById(categoryId);
	}
	
	public List<String> findAllName(){
		return categoryDao.findAllName();
	}
}
